/*
* Smart IP Camera
* Copyright (c) BZ <bzchen@allwinnertech.com>
*
* This file is part of SIPC.
*/
#ifndef Z_LOG_H
#define Z_LOG_H

#include <assert.h>

enum ZLogLevelE
{
    Z_LOG_DEBUG = 0,
    Z_LOG_INFO,
    Z_LOG_WARNING,
    Z_LOG_ERROR,
    Z_LOG_FAULT,
};

#ifdef __cplusplus
extern "C"
{
#endif

void ZLog(int level, char *file, int line, char *fmt, ...);

#ifdef __cplusplus
}
#endif

#define LogD(fmt, arg...) ZLog(Z_LOG_DEBUG, __FILE__, __LINE__, fmt, ##arg)

#define LogI(fmt, arg...) ZLog(Z_LOG_INFO, __FILE__, __LINE__, fmt, ##arg)

#define LogW(fmt, arg...) ZLog(Z_LOG_WARNING, __FILE__, __LINE__, fmt, ##arg)

#define LogE(fmt, arg...) ZLog(Z_LOG_ERROR, __FILE__, __LINE__, fmt, ##arg)

#define LogF(fmt, arg...) ZLog(Z_LOG_FAULT, __FILE__, __LINE__, fmt, ##arg)


#define Z_LOG_ASSERT(e, fmt, arg...)                           \
    do {                                                        \
        if (!(e))                                               \
        {                                                       \
            LogE("check (%s) failed:"fmt, #e, ##arg);       \
            assert(0);                                          \
        }                                                       \
    } while (0)

#define Z_ASSERT(e) Z_LOG_ASSERT(e, "")
    
#endif
